<?php

namespace app\admin\service;

use app\admin\model\UM as UM;
use ShidianUtil\Exception\DataNotExistException;
use app\admin\dao\ConsultingDao;
use app\common\model\Consulting;
use ShidianUtil\Utils\TimeUtil;
use think\Collection;

/**
 * Class QuestionConsultingService
 * @package app\admin\service
 */
class QuestionConsultingService
{
    // dao
    private ConsultingDao $consultingDao;

    public function __construct(ConsultingDao $consultingDao)
    {
        $this->consultingDao = $consultingDao;
    }

    /**
     * 列表
     * @param UM|null $user
     * @param int|null $page
     * @param int|null $page_size
     * @return array
     */
    public function index(?UM $user, $categoryId, $startTime, $endTime, $kw, ?int $page = null, ?int $page_size = null): array
    {
        if(is_numeric($endTime)){
            $endTime = TimeUtil::stamp(TimeUtil::DAY, $endTime, false);
        }
        //这里如果要修改查询，建议把查询放到dao层去
        return $this->consultingDao->listQuestionConsulting($categoryId, $startTime, $endTime, $kw, $page, $page_size);
    }

}
